<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //吃鸡
        function zhunbei() {
            return new Promise((resolve) => {
                setTimeout(function () {
                    console.log("1.准备清洗、切块");
                    resolve();
                }, 2000);
            })
        }
        //炒鸡
        function chaoji() {
            return new Promise((resolve) => {
                setTimeout(function () {
                    console.log("2.炒鸡");
                    resolve();
                }, 2000);
            })
        }

        //炖鸡
        function dunji() {
            return new Promise((resolve) => {
                setTimeout(function () {
                    console.log("3.炖鸡");
                    resolve();
                }, 2000);
            })
        }
        //加调料
        function tiaoliao() {
            return new Promise((resolve) => {
                setTimeout(function () {
                    console.log("4.加入调料");
                    resolve();
                }, 2000);
            })
        }
        //吃鸡
        function chiji() {
            return new Promise((resolve) => {
                setTimeout(function () {
                    console.log("5.吃鸡");
                    resolve();
                }, 2000);
            })
        }
        //可以使用 async await 按顺序调用 几个步骤
        async function task() {
            console.log("start");
            await zhunbei();
            await chaoji();
            await dunji();
            await tiaoliao();
            await chiji();
            console.log("end");
        }
        task();

        //解决地狱回调问题:
        //1. promise  、promise.all
        //2. async await
        //3. generator
    </script>
</body>

</html>